home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / bin / apport-bug < prev    next >
Text File  |  2009-11-03  |  2KB  |  96 lines

  1. #!/bin/sh -e
  2. # Determine the most appropriate Apport user interface (GTK/KDE/CLI) and file a
  3. # bug with it.
  4. #
  5. # Copyright (C) 2007 Canonical Ltd.
  6. # Author: Martin Pitt <martin.pitt@ubuntu.com>
  7. #
  8. # This program is free software; you can redistribute it and/or modify it
  9. # under the terms of the GNU General Public License as published by the
  10. # Free Software Foundation; either version 2 of the License, or (at your
  11. # option) any later version.  See http://www.gnu.org/copyleft/gpl.html for
  12. # the full text of the license.
  13.  
  14. # locate path of a particular program
  15. find_program() {
  16.     for p in /usr/local/bin /usr/bin /usr/local/share/apport /usr/share/apport; do
  17.     if [ -x $p/$1 ]; then
  18.         RET=$p/$1
  19.         return
  20.     fi
  21.     done
  22.     unset RET
  23. }
  24.  
  25. # determine which UIs are available, and where
  26. find_programs() {
  27.     find_program "apport-cli"
  28.     CLI="$RET"
  29.     find_program "apport-gtk"
  30.     GTK="$RET"
  31.     find_program "apport-kde"
  32.     KDE="$RET"
  33.  
  34.     # find a terminal emulator
  35. }
  36.  
  37. #
  38. # main
  39. #
  40.  
  41. # keep backwards compatibility with old documentation which says to use
  42. # ubuntu-bug -p packagename
  43. if [ $# = 2 ] && [ "$1" = '-p' -o "$1" = '-P' ]; then
  44.     shift
  45.     # Show warning about deprecated options.
  46.     echo "Warning: The options -p/-P are deprecated, please do not use them.  See $0 --help"
  47. fi
  48.  
  49. find_programs
  50.  
  51. if [ "$#" -gt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  52.     echo "Usage: $0 <pid>|<symptom name>|<package name>|<program path>|<.crash file>" >&2
  53.     exit 1
  54. fi
  55.  
  56. if [ "$#" = "0" ]; then
  57.     args="-f"
  58. else
  59.     args="$1"
  60. fi
  61.  
  62. # check for X
  63. if [ -z "$DISPLAY" ]; then
  64.     if [ -x "$CLI" ] ; then
  65.         "$CLI" "$args"
  66.     else
  67.         echo "\$DISPLAY is not set. You need apport-cli to make this program work." >&2
  68.         exit 1
  69.     fi
  70.  
  71. # do we have a running Gnome/KDE session?
  72. elif pgrep -u `id -u` -x gnome-session >/dev/null && \
  73.     [ -x "$GTK" ]; then
  74.     "$GTK" "$args"
  75. elif pgrep -u `id -u` -x ksmserver >/dev/null && \
  76.     [ -x "$KDE" ]; then
  77.     "$KDE" "$args"
  78.  
  79. # fall back to calling whichever is available
  80. elif [ -x "$GTK" ]; then
  81.     "$GTK" "$args"
  82. elif [ -x "$KDE" ]; then
  83.     "$KDE" "$args"
  84. elif [ -x "$CLI" ]; then
  85.     if [ -z "$TERM" ] && [ -x "$XTERM" ]; then
  86.          "$XTERM" -e "$CLI" "$args"
  87.     else
  88.         "$CLI" "$args"
  89.     fi
  90.  
  91. else
  92.     echo "Neither apport-gtk, apport-kde or apport-cli are installed. Install either to make this program work." >&2
  93.     exit 1
  94. fi
  95.  
  96.